package com.puzzlebazar.client.puzzle.model;

public class MoveMessage extends MoveImpl {

	/**
	 * 
	 */
	private static final long serialVersionUID = 690192671750040853L;
	
	
	private String previousMessage;
	private String message;

	/**
	 * Only for serialization
	 */
	protected MoveMessage() {
		super();
	}
	
	/**
	 * A move that can be used to display a message
	 * 
	 * @param message The message to display (null or empty for no message)
	 * @param previousMessage The message to remove
	 * @param time The time of this move
	 */
	public MoveMessage(String message, String previousMessage, long time) {
		super(time);
		this.message = message;
		this.previousMessage = previousMessage;
	}

	@Override
	public Move apply(PuzzleModel model) throws Exception {
		return model.setMessage( message, time );
	}

	@Override
	public Move unapply(PuzzleModel model) throws Exception {
		return model.setMessage( previousMessage, time );
	}
	
	/**
	 * Access the message associated with this move
	 * 
	 * @return The message associated with this move
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * Changes the message attached to that move
	 * 
	 * @param message The new message
	 */
	public void setMessage(String message) {
		this.message = message;
	}

	/**
	 * Changes the previous message attached to that move
	 * 
	 * @param previousMessage The new previous message
	 */
	public void setPreviousMessage(String previousMessage) {
		this.previousMessage = previousMessage;
	}

	

	
	
}
